﻿using WorkLogger.Client.Services;

namespace WorkLogger.Client.Commands {
	public class CommandFactory : ICommandFactory {
		private readonly IWorkDayManager workDayManager;
		private readonly AppOptions appOptions;
		private readonly WorkTimeCalculator workTimeCalculator;
		private readonly ISystemClock systemClock;

		public CommandFactory(IWorkDayManager workDayManager,
		                      AppOptions appOptions,
		                      WorkTimeCalculator workTimeCalculator,
		                      ISystemClock systemClock) {
			this.workDayManager = workDayManager;
			this.appOptions = appOptions;
			this.workTimeCalculator = workTimeCalculator;
			this.systemClock = systemClock;
		}

		public ICommand CreateResumeWorkingCommand() {
			var lunchCheckService = new LunchCheckService(workDayManager, systemClock, appOptions);
			var startDayCheckService = new StartDayCheckService(workDayManager);
			return new ResumeWorkingCommand(lunchCheckService, startDayCheckService);
		}

		public ICommand CreateTickCommand() {
			return new TickCommand(appOptions, workDayManager, workTimeCalculator, systemClock);
		}
	}
}